#include "Thread.hpp"
#include <iostream>
#include <unistd.h>
#include <string>
#include <vector>

using namespace ThreadMoudle;

void *Test(std::string &name)
{
    while (true)
    {
        std::cout << name << ", is runing... " << std::endl;
        sleep(1);
    }

    return nullptr;
}

int main()
{
    std::vector<Thread> tids;
    for (int i = 0; i < 5; i++)
    {
        std::string name = "thread_" + std::to_string(i + 1);
        Thread *t = new Thread(name, Test);
        tids.emplace_back(name, Test);
    }
    sleep(3);

    for (auto &t : tids)
    {
        t.Start();
    }

    sleep(10);

    for (auto &t : tids)
        std::cout << t.Name() << "---" << t.Status() << std::endl;

    sleep(2);
    for (auto &t : tids)
    {
        t.Stop();
    }

    std::cout << "===================================" << std::endl;
    for (auto &t : tids)
        std::cout << t.Name() << "---" << t.Status() << std::endl;

    sleep(3);
    for (auto &t : tids)
    {
        t.Jion();
    }

    return 0;
}
